// pages/addPoint/about.js
Page({

  /**
   * 页面的初始数据
   */
  data: {
    student: "",
    course: "",
    options:""
  },

  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.getStudent(options.id)
    this.getPoint(JSON.parse(options.course))
    this.setData({
      options
    })
  },
  getStudent(id) {
    let that = this
    wx.request({
      url: 'http://localhost:8080/Examination_System_war/wxstudent/getStudent',
      data: {
        id
      },
      header: { 'content-type': 'application/x-www-form-urlencoded' },
      method: 'GET',
      dataType: 'json',
      responseType: 'text',
      success: (result) => {
        that.setData({
          student: result.data,
        })
      },
      fail: () => { },
      complete: () => { }
    });
  }
  ,
  formSubmit: function (e) {
    var that = this;
    var courseId = e.detail.value.collegeID;
    var point = e.detail.value.point;
    var userid = e.detail.value.userid;
    wx.request({
      url: 'http://localhost:8080/Examination_System_war/wxteacher/wxCourseMarkOne',
      data: {
        courseId,
        point,
        userid,
      },
      header: { 'content-type': 'application/x-www-form-urlencoded' },
      method: 'POST',
      dataType: 'json',
      responseType: 'text',
      success: (result) => {
        wx.showToast({
          title: '修改成功',
          icon: 'none',
          image: '',
          duration: 1500,
          mask: false,
          success: (result) => {
        wx.navigateBack({
        });
          },
          fail: () => {},
          complete: () => {}
        });
      },
      fail: () => { },
      complete: () => { }
    });
  },
  getPoint(course) {
    this.setData({
      course
    })
  },
})